from datetime import datetime
import os


class Document(object):
  
  def __init__(self):
    self.title = ''
    self.content = ''
    self.attachment = None
    self.tags = []
    self.wordIndex = []
    self.physicalLocation = None
    self.size = 0
    self.timestamp = datetime.fromtimestamp(0)

  @staticmethod
  def from_file(file):
    doc = Document()
    doc.attachment = file
    fileinfo = os.stat(file)
    doc.title = file.split('/')[-1][:-4]
    doc.size = fileinfo.st_size
    doc.timestamp = datetime.fromtimestamp(fileinfo.st_mtime)
    return doc

